package com.bijava.controller;

import com.bijava.service.UploadService;
import io.minio.messages.Bucket;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author bijava
 * @version 1.0
 * @since 20-9-8
 */
@RestController
public class UploadController {
    @Resource
    private UploadService uploadService ;

    @GetMapping("/bucketList")
    public List<Bucket> bucketList() throws Exception {
        return uploadService.bucketList();
    }

    @GetMapping("/uploadHtml")
    public String uploadHtml() throws Exception {
        String fileName = "1285041140.xls";
        String filePath = "/home/swifty/Documents/1285041140.xls";
        return uploadService.uploadHtml(fileName,filePath);
    }

    @GetMapping("/uploadImg")
    public String uploadImg() throws Exception {
        String imgName = "2020072702.jpg";
        String imgPath = "/data/home/swifty/Pictures/Headers/2020072702.jpg";
        return uploadService.uploadImg(imgName,imgPath);
    }

    @GetMapping("/uploadString")
    public String uploadString() throws Exception {
        return uploadService.uploadString();
    }

    @GetMapping("/download")
    public void download(HttpServletResponse response) throws Exception {
        uploadService.download(response);
    }
}